package org.example.aienglishapp.dto.article;

import org.example.aienglishapp.entity.article.Article;

public class ArticleConverter {

    public static Article toEntity(ArticleDTO dto) {
        if (dto == null) {
            return null;
        }
        Article entity = new Article();
        entity.setArticleId(dto.getArticleId());
        entity.setTitle(dto.getTitle());
        entity.setOriginalText(dto.getOriginalText());
        return entity;
    }

    public static ArticleDTO toDTO(Article entity) {
        if (entity == null) {
            return null;
        }
        ArticleDTO dto = new ArticleDTO();
        dto.setArticleId(entity.getArticleId());
        dto.setTitle(entity.getTitle());
        dto.setOriginalText(entity.getOriginalText());
        return dto;
    }
}
